package org.example.Controller;

import jakarta.annotation.Resource;
import org.example.common.Result;
import org.example.pojo.Address;
import org.example.service.AddressService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("address")
public class AdressController {
    @Resource
    private AddressService addressService;
    @PostMapping("/all")
    public Result getall( Integer userId){
        Result result=addressService.getall(userId);
        return result;
    }
    @PostMapping("/add")
    public Result add(@RequestBody Address address){
        Result result=addressService.add(address);
        return result;
    }
    @PostMapping("/update")
    public Result update(@RequestBody Address address){
        Result result=addressService.updateaddrress(address);
        return result;
    }
    @PostMapping("/delete")
    public Result delete(Integer id){
        Result result=addressService.deleteById(id);
        return result;
    }

}
